package com.factorit.beans;

import java.util.List;

import org.joone.engine.FullSynapse;
import org.joone.engine.LinearLayer;
import org.joone.engine.SigmoidLayer;
import org.joone.engine.SimpleLayer;
import org.joone.net.NeuralNet;

/**
 * Red Neuronal utilizada en la simulacion
 * @author Mural
 *
 */
public class NeuronalNet extends NeuralNet {
	
	private static final long serialVersionUID = 7775151677062002906L;
	
	/**
	 * Contructor indicando la cantidad de layers a utilizar
	 * @param layers
	 */
	public NeuronalNet (Integer layerCount, List<Integer> rows) {
		
		//private static final Logger logger = new Logger();
		super();
		
		FullSynapse prevSynapse = null;
		FullSynapse outSynapse = null;
		SimpleLayer layer = null;
		
		for (int i=1; i<=layerCount; i++) {
			
			//Cracion de la layer
			if (i == 1) {
				layer = new LinearLayer();
			} else {
				layer = new SigmoidLayer();
			}
			//Se le asigna la cantidad de neuronas para esa layer
			layer.setRows(rows.get(i-1));
			
			
			//Se crean las relaciones entre las neuronas a traves de las synapsis
			outSynapse = new FullSynapse();
			if (i != 1) {
				layer.addOutputSynapse(prevSynapse);
			}
			
			if (i != layerCount) {
				layer.addOutputSynapse(outSynapse);
				prevSynapse = outSynapse;
			}
			
			if (i == 1) {
				this.addLayer(layer, NeuralNet.INPUT_LAYER);
			} else if (i == layerCount) {
				this.addLayer(layer, NeuralNet.OUTPUT_LAYER);
			} else {
				this.addLayer(layer, NeuralNet.HIDDEN_LAYER);				
			}
		}
	}
	

}
